package com.cangshi.service;

import com.cangshi.dao.*;
import com.cangshi.entity.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by Eoly on 2017/1/16.
 */
@Service("userService")
public class UserServiceImpl implements UserService{

    @Autowired
    UserMapper userMapper;

    @Autowired
    LoginInformationMapper loginInformationMapper;

    @Autowired
    UserLoginPswMapper userLoginPswMapper;

    @Autowired
    UserPayPswMapper userPayPswMapper;

    @Autowired
    UserRegistionMapper userRegistionMapper;

    @Autowired
    UserBaseInfoMapper userBaseInfoMapper;



    public int userRegistered(UserRegistion userRegistion) {
        return userRegistionMapper.insertSelective(userRegistion);
    }

    public int getIdFromLastRegistion() {
        return userRegistionMapper.selectLastId();
    }

    public UserLoginPsw getLoginPswByPhoneNumber(String phoneNum) {
        return userLoginPswMapper.selectByUserPhoneNumber(phoneNum);
    }

    public UserBaseInfo getUserBaseInfoByUserId(Integer userId) {
        return userBaseInfoMapper.selectByUserId(userId);
    }


    public UserPayPsw getPayPswByPhoneNumber(String phoneNum) {
        return userPayPswMapper.selectByUserPhoneNumber(phoneNum);
    }

    public UserLoginPsw getLoginPswByUserId(Integer userId) {
        return null;
    }

    public UserPayPsw getPayPswByUserId(Integer userId) {
        return null;
    }

    public User getUserById(Integer userId) {
        return userMapper.selectByPrimaryKey(userId);
    }

    public int addRecordOfLogin(LoginInformation loginInformation) {
        return loginInformationMapper.insertSelective(loginInformation);
    }

    public int modifyUser(User user) {
        return userMapper.updateByPrimaryKeySelective(user);
    }
}
